﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RATSharp.Collection
{
    /// <summary>
    /// MultiMap collection implementation
    /// </summary>
    /// <typeparam name="K">key</typeparam>
    /// <typeparam name="V">Value</typeparam>
    public class MultiDictionary<K, V> : Dictionary<K, List<V>>
    {
        /// <summary>
        /// add new item to collection
        /// </summary>
        /// <param name="key">key</param>
        /// <param name="value">value</param>
        public void Add(K key, V value)
        {
            List<V> values;
            if (!this.TryGetValue(key, out values))
            {
                values = new List<V>();
                this.Add(key, values);
            }
            values.Add(value);
        }

    }
}
